home *** CD-ROM | disk | FTP | other *** search
/ Aminet 41 / Aminet 41 (2001)(Schatztruhe)[!][Feb 2001].iso / Aminet / gfx / edit / AmiCAD_2.07.lha / AmiCAD / ARexx / Cartouche.amiCAD < prev    next >
Text File  |  2000-11-04  |  5KB  |  173 lines

  1. /* Script ARexx permettant le tracé d'un cartouche dans une fenêtre AmiCAD */
  2. /* Chez Corbin, Vendredi 3 Octobre 1997, Version 1.00, © R.Florac */
  3. /* Version 1.01, 2 Novembre 1997, trait vertical rajouté dans cartouche */
  4. /* Version 1.02, 23 janvier 1998, ajout titre, date, etc... */
  5. /* Version 1.03, 12 février 1998, test longueurs chaînes pour ajustement largeur */
  6. /* Version 1.04, 24 mai 1998, test présence rexxlocaldates.library */
  7. /* Version 1.05, 21 juin 1998, ajout test après choix emplacement cartouche pour arrêt */
  8. /* Version 1.06, 14 juillet 1998, modification tracé lignes (lignes quelconques) */
  9. /* Version 1.06a, 15 janvier 1999, remplacement fonction ASK par ASKTEXT */
  10. /* Version 1.07, 13 avril 2000, modification fonctions SAVEALL, WWIDTH, WHEIGHT, ajout SETSCALE */
  11. /* Version 1.08, 4 novembre 2000, localisation anglais/français */
  12. /* $VER: Cartouche.AmiCAD 1.08 (© R.Florac, 4/11/00) */
  13.  
  14. options results
  15.  
  16. 'LANGUAGE'
  17. if result="français.language" then fr=1
  18. else fr=0
  19.  
  20. if fr=1 then organisation="LYCÉE Bernard PALISSY SAINTES"
  21. else organisation="AmiCAD © R.Florac 2000"
  22.  
  23. signal on error
  24. signal on syntax
  25.  
  26. if (~show('L','rexxlocaldates.library')) then
  27.   call addlib('rexxlocaldates.library',0,-30,0)
  28.  
  29. if (show('L','rexxlocaldates.library')) then do
  30.     Ib = OpenLocale()
  31.     jour = FormatDate(Ib, ,"%A %e %B %Y")
  32. end
  33. else do
  34.     'DATE(1)'; jour=result
  35. end
  36.  
  37. 'WWIDTH'; l = result; lc = result % 3
  38. 'WHEIGHT'; h =result
  39. 'ROTATE(0,0):SYMMETRY(0,0):SETSCALE(0,100,100)'
  40.  
  41. if fr=1 then 'SELECT("Emplacement du cartouche"+CHR(10)+"En haut à gauche"+CHR(10)+"En haut à droite"+CHR(10)+"En haut au centre"+CHR(10)+"En bas au centre"+CHR(10)+"En bas à droite"+CHR(10)+"En bas à gauche")'
  42. else 'SELECT("Placement of the cartouche"+CHR(10)+"Top left"+CHR(10)+"Top right"+CHR(10)+"Top center"+CHR(10)+"Bottom center"+CHR(10)+"Bottom right"+CHR(10)+"Bottom left")'
  43. c = result
  44. if c<1 then exit    /* Version 1.05 */
  45.  
  46. if fr=1 then 'ASKTEXT("Titre du cartouche","")'
  47. else 'ASKTEXT("Title of the cartouche","")'
  48. titre = result
  49. if titre='' then exit
  50.  
  51. if lc<260 then lc=260
  52. 'TXWIDTH("'organisation'")'; lt = result
  53. if lt>lc-10 then lc=lt+10
  54. 'TXWIDTH("'titre'")'; lt = result
  55. if lt>lc-10 then lc=lt+10
  56. dx=(lc+5)%4*3
  57. 'TXWIDTH("'jour'")'; lt = result
  58. if lt>dx-10 then do
  59.     dx=lt+10
  60.     lc=dx%3*4
  61. end
  62.  
  63. select
  64.     when c = 1 then do        /* En haut à gauche */
  65.     x0 = 5
  66.     x1 = lc + 5
  67.     y0 = 5
  68.     y1 = 85
  69.     bh = 0
  70.     bb = 1
  71.     bg = 0
  72.     bd = 1
  73.     end
  74.     when c = 2 then do        /* En haut à droite */
  75.     x0 = l - lc - 5
  76.     x1 = l - 5
  77.     y0 = 5
  78.     y1 = 85
  79.     bh = 0
  80.     bb = 1
  81.     bg = 1
  82.     bd = 0
  83.     end
  84.     when c = 3 then do        /* En haut au centre */
  85.     x0 = l % 2 - lc % 2
  86.     x1 = x0 + lc
  87.     y0 = 5
  88.     y1 = 85
  89.     bh = 0
  90.     bb = 1
  91.     bg = 1
  92.     bd = 1
  93.     end
  94.     when c = 4 then do        /* En bas au centre */
  95.     x0 = l % 2 - lc % 2
  96.     x1 = x0 + lc
  97.     y0 = h - 85
  98.     y1 = h - 5
  99.     bh = 1
  100.     bb = 0
  101.     bg = 1
  102.     bd = 1
  103.     end
  104.     when c = 6 then do        /* En bas à gauche */
  105.     x0 = 5
  106.     x1 = 5 + lc
  107.     y0 = h - 85
  108.     y1 = h - 5
  109.     bh = 1
  110.     bb = 0
  111.     bg = 0
  112.     bd = 1
  113.     end
  114.     when c = 5 then do        /* En bas à droite */
  115.     x0 = l - lc - 5
  116.     x1 = l - 5
  117.     y0 = h - 85
  118.     y1 = h - 5
  119.     bh = 1
  120.     bb = 0
  121.     bg = 1
  122.     bd = 0
  123.     end
  124.     otherwise exit
  125. end
  126.  
  127. /* sauvegarde du contexte, dessin du contour */
  128. 'SAVEALL:DRAWMODE(-2):DRAW(5,5,'l-5',5):DRAW('l-5',5,'l-5','h-5')'
  129. 'DRAW('l-5','h-5',5,'h-5'):DRAW(5,'h-5',5,5)'
  130.  
  131. /* Tracé du bord horizontal haut */
  132. if bh > 0 then 'DRAW('x0','y0','x1','y0')'
  133. /* Tracé du bord horizontal bas */
  134. if bb > 0 then 'DRAW('x0','y1','x1','y1')'
  135. /* Tracé du bord vertical gauche */
  136. if bg > 0 then 'DRAW('x0','y0','x0','y1')'
  137. /* Tracé du bord vertical droit */
  138. if bd > 0 then 'DRAW('x1','y0','x1','y1')'
  139. /* Tracé des lignes horizontales intermédiaires */
  140. 'DRAW('x0','y0+20','x1','y0+20')'
  141. 'DRAWMODE(-1):DRAW('x0','y0+40','x1','y0+40'):DRAW('x0','y0+60','x1','y0+60')'
  142. /* Tracé de la ligne verticale intermédiaire */
  143. 'DRAW('dx+x0','y0+40','dx+x0','y1')'
  144.  
  145. 'SETSCALE(0,100,100)'
  146. call centrer_texte(organisation,x0,x1,y0+15)
  147. call centrer_texte(titre,x0,x1,y0+35)
  148. call centrer_texte(jour,x0,x0+dx,y0+75)
  149. call centrer_texte("Document Numéro 1/1",x0,x0+dx,y0+55)
  150. call centrer_texte("REV 1",x0+dx,x1,y0+55)
  151. call centrer_texte("AmiCAD",x0+dx,x1,y0+75)
  152.  
  153. exit
  154.  
  155. centrer_texte: procedure
  156.     parse arg texte, xg, xd, y
  157.     'TXWIDTH("'texte'")'; l = result
  158.     l = (xd-xg-l)%2
  159.     'WRITE("'texte'",'xg+l','y')'
  160.     return
  161.  
  162. /* Traitement des erreurs, interruption du programme */
  163. syntax:
  164. erreur=RC
  165. if fr=1 then 'MESSAGE("Script Cartouche.AmiCAD:"+CHR(10)+"Erreur de syntaxe"+CHR(10)+"en ligne 'SIGL'"+CHR(10)+"'errortext(erreur)'")'
  166. else 'MESSAGE("Script Cartouche.AmiCAD:"+CHR(10)+"Syntax error"+CHR(10)+"in line 'SIGL'"+CHR(10)+"'errortext(erreur)'")'
  167. exit
  168.  
  169. error:
  170. if fr=1 then 'MESSAGE("Script Cartouche.AmiCAD:"+CHR(10)+"Erreur en ligne 'SIGL'")'
  171. else 'MESSAGE("Script Cartouche.AmiCAD:"+CHR(10)+"Error in line 'SIGL'")'
  172. exit
  173.